Skip to content

Conversation

@sirreal
Copy link
Member

@sirreal sirreal commented Dec 17, 2025

Fix class names or filename to match PHPUnit expectations.

PHPUnit can be run with a filename argument:

phpunit [options] UnitTest.php

However, certain test files and test suite class names do not align with PHPUnit expectations and it may fail to run any tests, for example:

./vendor/bin/phpunit tests/phpunit/tests/rest-api/rest-controller.php

Class rest-controller could not be found in /Users/jonsurrell/a8c/wordpress-develop/trunk/tests/phpunit/tests/rest-api/rest-controller.php

Trac ticket: https://core.trac.wordpress.org/ticket/64225


I used this script (and some variations) to detect the files with this problem. The idea being that no tests actually match the filter (so the suite should never fail) but the suite does fail if the test class cannot be found:

#!/usr/bin/env zsh

set -u

echo > bad-test-filename.txt
for f in tests/phpunit/tests/**/*.php
do
	echo "Testing: $f"
	WP_TESTS_SKIP_INSTALL=1 ./vendor/bin/phpunit --filter='no run no tests' "$f" > /dev/null
	if [ $? -ne 0 ]
	then
		echo -e "\e[0;31mProblem on $f\e[0m"
		echo "$f" >> bad-test-filename.txt
	fi
done
bad test files on trunk (alphabetized)

Note that most of the base.php classes are abstract classes meant to be extended, not actually run as a test suite.

tests/phpunit/tests/admin/plugin-dependencies/base.php
tests/phpunit/tests/admin/themeBodyClass.php
tests/phpunit/tests/block-bindings/postMetaSource.php
tests/phpunit/tests/block-bindings/wp-block-get-block-bindings-processor.php
tests/phpunit/tests/block-processor/wpBlockProcessor-BlockProcessing.php
tests/phpunit/tests/block-processor/wpBlockProcessor.php
tests/phpunit/tests/block-supports/aria-label.php
tests/phpunit/tests/block-supports/block-style-variations.php
tests/phpunit/tests/block-supports/block-visibility.php
tests/phpunit/tests/block-template-utils.php
tests/phpunit/tests/block-template.php
tests/phpunit/tests/block-templates/base.php
tests/phpunit/tests/block-templates/getTemplateHierarchy.php
tests/phpunit/tests/blocks/getBlockAssetUrl.php
tests/phpunit/tests/blocks/renderCommentTemplate.php
tests/phpunit/tests/build-visual-html-tree.php
tests/phpunit/tests/category/walkerCategory.php
tests/phpunit/tests/compat/wpCodePointCount.php
tests/phpunit/tests/customize/custom-css-setting.php
tests/phpunit/tests/customize/nav-menu-item-setting.php
tests/phpunit/tests/customize/nav-menu-setting.php
tests/phpunit/tests/customize/nav-menus.php
tests/phpunit/tests/customize/selective-refresh-ajax.php
tests/phpunit/tests/customize/selective-refresh.php
tests/phpunit/tests/editor/classic-to-block-menu-converter.php
tests/phpunit/tests/editor/navigation-fallback.php
tests/phpunit/tests/filesystem/base.php
tests/phpunit/tests/filesystem/findFolder.php
tests/phpunit/tests/filesystem/wpFilesystemDirect/base.php
tests/phpunit/tests/filesystem/wpFilesystemDirect/construct.php
tests/phpunit/tests/filesystem/wpFilesystemDirect/cwd.php
tests/phpunit/tests/filesystem/wpFilesystemDirect/exists.php
tests/phpunit/tests/fonts/font-face/base.php
tests/phpunit/tests/fonts/font-face/wp-font-face-tests-dataset.php
tests/phpunit/tests/fonts/font-face/wpFontFace/generateAndPrint.php
tests/phpunit/tests/fonts/font-face/wpFontFaceResolver/getFontsFromStyleVariations.php
tests/phpunit/tests/fonts/font-face/wpFontFaceResolver/getFontsFromThemeJson.php
tests/phpunit/tests/fonts/font-face/wpPrintFontFaces.php
tests/phpunit/tests/fonts/font-face/wpPrintFontFacesFromStyleVariations.php
tests/phpunit/tests/fonts/font-library/postTypes.php
tests/phpunit/tests/fonts/font-library/wpFontCollection/__construct.php
tests/phpunit/tests/fonts/font-library/wpFontLibrary/base.php
tests/phpunit/tests/fonts/font-library/wpFontLibrary/getFontCollection.php
tests/phpunit/tests/fonts/font-library/wpFontLibrary/getFontCollections.php
tests/phpunit/tests/fonts/font-library/wpFontLibrary/registerFontCollection.php
tests/phpunit/tests/fonts/font-library/wpFontLibrary/unregisterFontCollection.php
tests/phpunit/tests/fonts/font-library/wpFontsDir.php
tests/phpunit/tests/formatting/deprecatedUtfEncodeDecode.php
tests/phpunit/tests/functions/isNewDay.php
tests/phpunit/tests/html-api/bootstrap.php
tests/phpunit/tests/html-api/wpHtmlProcessor-bookmark.php
tests/phpunit/tests/html-api/wpHtmlProcessor-serialize.php
tests/phpunit/tests/html-api/wpHtmlProcessorHtml5lib.php
tests/phpunit/tests/html-api/wpHtmlTagProcessor-bookmark.php
tests/phpunit/tests/html-api/wpHtmlTagProcessor-token-scanning.php
tests/phpunit/tests/http/base.php
tests/phpunit/tests/https-detection.php
tests/phpunit/tests/https-migration.php
tests/phpunit/tests/image/base.php
tests/phpunit/tests/image/editorGd.php
tests/phpunit/tests/image/editorImagick.php
tests/phpunit/tests/image/intermediateSize.php
tests/phpunit/tests/image/resize.php
tests/phpunit/tests/image/resizeGd.php
tests/phpunit/tests/image/resizeImagick.php
tests/phpunit/tests/image/siteIcon.php
tests/phpunit/tests/includes/factory.php
tests/phpunit/tests/includes/helpers.php
tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-bind.php
tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-class.php
tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-context.php
tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-each.php
tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-interactive.php
tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-router-region.php
tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-style.php
tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-text.php
tests/phpunit/tests/js-interop.php
tests/phpunit/tests/l10n/phpmailerTranslations.php
tests/phpunit/tests/l10n/wpTranslationController.php
tests/phpunit/tests/l10n/wpTranslations.php
tests/phpunit/tests/l10n/wpTranslationsConvert.php
tests/phpunit/tests/load/wpDebugMode.php
tests/phpunit/tests/load/wpGetDevelopmentMode.php
tests/phpunit/tests/media/testcase-adjacent-image-link.php
tests/phpunit/tests/media/wpImageTagAddDecodingAttr.php
tests/phpunit/tests/media/wpImgTagAddWidthAndHeightAttr.php
tests/phpunit/tests/media/wpPlaylistShortcode.php
tests/phpunit/tests/menu/nav-menu.php
tests/phpunit/tests/menu/walker-nav-menu-edit.php
tests/phpunit/tests/menu/walker-nav-menu.php
tests/phpunit/tests/menu/wp-nav-menu.php
tests/phpunit/tests/meta/registerMeta.php
tests/phpunit/tests/multisite/populateNetworkHooks.php
tests/phpunit/tests/oembed/filterResult.php
tests/phpunit/tests/oembed/filterTitleAttributes.php
tests/phpunit/tests/oembed/getResponseData.php
tests/phpunit/tests/oembed/postEmbedUrl.php
tests/phpunit/tests/oembed/WpEmbed.php
tests/phpunit/tests/oembed/wpOembed.php
tests/phpunit/tests/option/wpDetermineOptionAutoloadValue.php
tests/phpunit/tests/pomo/pluralForms.php
tests/phpunit/tests/post/nav-menu.php
tests/phpunit/tests/post/primePostParentsCaches.php
tests/phpunit/tests/post/thumbnails.php
tests/phpunit/tests/post/walkerPage.php
tests/phpunit/tests/post/wpGetAutoSave.php
tests/phpunit/tests/post/wpPostType.php
tests/phpunit/tests/query/lazyLoadCommentMeta.php
tests/phpunit/tests/query/lazyLoadTermMeta.php
tests/phpunit/tests/query/verboseRewriteRules.php
tests/phpunit/tests/rest-api.php
tests/phpunit/tests/rest-api/application-passwords.php
tests/phpunit/tests/rest-api/rest-application-passwords-controller.php
tests/phpunit/tests/rest-api/rest-attachments-controller.php
tests/phpunit/tests/rest-api/rest-autosaves-controller.php
tests/phpunit/tests/rest-api/rest-block-directory-controller.php
tests/phpunit/tests/rest-api/rest-block-renderer-controller.php
tests/phpunit/tests/rest-api/rest-block-type-controller.php
tests/phpunit/tests/rest-api/rest-blocks-controller.php
tests/phpunit/tests/rest-api/rest-categories-controller.php
tests/phpunit/tests/rest-api/rest-comments-controller.php
tests/phpunit/tests/rest-api/rest-controller.php
tests/phpunit/tests/rest-api/rest-global-styles-controller.php
tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php
tests/phpunit/tests/rest-api/rest-navigation-fallback-controller.php
tests/phpunit/tests/rest-api/rest-pages-controller.php
tests/phpunit/tests/rest-api/rest-pattern-directory-controller.php
tests/phpunit/tests/rest-api/rest-plugins-controller.php
tests/phpunit/tests/rest-api/rest-post-meta-fields.php
tests/phpunit/tests/rest-api/rest-post-statuses-controller.php
tests/phpunit/tests/rest-api/rest-post-types-controller.php
tests/phpunit/tests/rest-api/rest-posts-controller.php
tests/phpunit/tests/rest-api/rest-request-validation.php
tests/phpunit/tests/rest-api/rest-request.php
tests/phpunit/tests/rest-api/rest-revisions-controller.php
tests/phpunit/tests/rest-api/rest-schema-sanitization.php
tests/phpunit/tests/rest-api/rest-schema-setup.php
tests/phpunit/tests/rest-api/rest-schema-validation.php
tests/phpunit/tests/rest-api/rest-search-controller.php
tests/phpunit/tests/rest-api/rest-server.php
tests/phpunit/tests/rest-api/rest-settings-controller.php
tests/phpunit/tests/rest-api/rest-sidebars-controller.php
tests/phpunit/tests/rest-api/rest-site-health-controller.php
tests/phpunit/tests/rest-api/rest-tags-controller.php
tests/phpunit/tests/rest-api/rest-taxonomies-controller.php
tests/phpunit/tests/rest-api/rest-term-meta-fields.php
tests/phpunit/tests/rest-api/rest-test-controller.php
tests/phpunit/tests/rest-api/rest-themes-controller.php
tests/phpunit/tests/rest-api/rest-users-controller.php
tests/phpunit/tests/rest-api/rest-widget-types-controller.php
tests/phpunit/tests/rest-api/rest-widgets-controller.php
tests/phpunit/tests/rest-api/wpIsRestEndpoint.php
tests/phpunit/tests/rewrite/rewriteTags.php
tests/phpunit/tests/style-engine/styleEngine.php
tests/phpunit/tests/term/getTermParentsList.php
tests/phpunit/tests/term/taxQuery.php
tests/phpunit/tests/term/termCounts.php
tests/phpunit/tests/term/wpGenerateTagCloud.php
tests/phpunit/tests/term/wpTaxonomy.php
tests/phpunit/tests/theme-previews.php
tests/phpunit/tests/theme/autoloadThemeMods.php
tests/phpunit/tests/theme/base.php
tests/phpunit/tests/theme/wpGetBlockCssSelector.php
tests/phpunit/tests/unicode/wpIsValidUtf8.php
tests/phpunit/tests/user/queryCache.php
tests/phpunit/tests/widgets/wpBlockThemeRegisterClassicSidebar.php
--- **This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See [GitHub Pull Requests for Code Review](https://make.wordpress.org/core/handbook/contribute/git/github-pull-requests-for-code-review/) in the Core Handbook for more details.**

@github-actions
Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

* @group https-migration
*/
class Tests_HTTPS_Migration extends WP_UnitTestCase {
class Tests_HttpsMigration extends WP_UnitTestCase {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class Tests_HttpsMigration extends WP_UnitTestCase {
class Tests_HTTPSMigration extends WP_UnitTestCase {

* @group https-detection
*/
class Tests_HTTPS_Detection extends WP_UnitTestCase {
class Tests_HttpsDetection extends WP_UnitTestCase {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class Tests_HttpsDetection extends WP_UnitTestCase {
class Tests_HTTPSDetection extends WP_UnitTestCase {

* @coversDefaultClass WP_User_Query
*/
class Tests_User_Query_Cache extends WP_UnitTestCase {
class Tests_User_QueryCache extends WP_UnitTestCase {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class Tests_User_QueryCache extends WP_UnitTestCase {
class Tests_User_QueryCache extends WP_UnitTestCase {

*/

class Tests_WpIsValidUtf8TestCase extends WP_UnitTestCase {
class Tests_Unicode_WpIsValidUtf8 extends WP_UnitTestCase {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class Tests_Unicode_WpIsValidUtf8 extends WP_UnitTestCase {
class Tests_Unicode_WpIsValidUTF8 extends WP_UnitTestCase {

* @group formatting
*/
class Tests_DeprecatedUtf8EncodeDecodeTest extends WP_UnitTestCase {
class Tests_Formatting_DeprecatedUtfEncodeDecode extends WP_UnitTestCase {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class Tests_Formatting_DeprecatedUtfEncodeDecode extends WP_UnitTestCase {
class Tests_Formatting_DeprecatedUTFEncodeDecode extends WP_UnitTestCase {

@sirreal sirreal force-pushed the tests/fix-test-class-name-filename-match branch from f6cb549 to ae01369 Compare December 17, 2025 19:20
@sirreal
Copy link
Member Author

sirreal commented Dec 18, 2025

Abandoning this based on https://core.trac.wordpress.org/ticket/62004.

@sirreal sirreal closed this Dec 18, 2025
@sirreal sirreal deleted the tests/fix-test-class-name-filename-match branch December 18, 2025 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant